package com.usian.admin.controller.v1;

import com.usian.admin.service.AdminService;
import com.usian.apis.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/admin/api/vl/channel")
@Api(value = "频道管理",tags = "channel",description = "频道管理API")
public class AdChannelController implements AdChannelControllerApi {
    @Autowired
    private AdminService adminService;

    //根据name查询对应的channel数据
    @PostMapping("/list")
    @Override
    @ApiOperation(value = "查询频道的信息",notes = "分页查询")
    @ApiImplicitParam(name = "channelDto",type = "ChannelDto",value = "分页参数")
    public ResponseResult findByNameAndPage(@RequestBody ChannelDto channelDto) {
        return adminService.findByNameAndPage(channelDto);
    }

    @PostMapping("/save")
    @Override
    public ResponseResult save(@RequestBody AdChannel channel) {
        return adminService.saveChannel(channel);
    }

    @PostMapping("/update")
    @Override
    public ResponseResult update(@RequestBody AdChannel channel) {
        return adminService.update(channel);
    }

    @GetMapping("/deleteById/{id}")
    @Override
    public ResponseResult deleteById(@PathVariable Integer id) {
        return adminService.deleteById(id);
    }

}
